package com.feihong.txgw.ui.activity.user;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.feihong.txgw.R;

/**
 * @name txgw_app
 * @class name：com.feihong.txgw.ui.activity.user
 * @class describe: 选择性别
 * @author wangziheng
 * @time 2017/9/1 12:30
 * @change
 * @chang time
 * @class describe
 */
public class SelectSexActivity extends Activity implements View.OnClickListener{
    private TextView mManTv,mWomenTv,mCannelTv;
    private Intent mIntent;
    public static String SELECT_SEX_KEY = "selectSex";
    /**
     *  男
     */
    public static int MAN_VALUE = 1;
    /**
     * 女
     */
    public static int WOMEN_VALUE = 2;
    /**
     * 取消
     */
    public static int CANNEL_VALYE = 0;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_change_sex);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mManTv = (TextView) findViewById(R.id.dialog_Title_tv);
        mWomenTv = (TextView) findViewById(R.id.dialog_Content_tv);
        mCannelTv = (TextView) findViewById(R.id.dialog_cannel_tv);
        mManTv.setTextColor(getResources().getColor(R.color.appRed));
        mWomenTv.setTextColor(getResources().getColor(R.color.appRed));
        mCannelTv.setTextColor(getResources().getColor(R.color.appRed));
        mManTv.setText("男");
        mWomenTv.setText("女");
        mCannelTv.setText("取消");
        mManTv.setOnClickListener(this);
        mWomenTv.setOnClickListener(this);
        mCannelTv.setOnClickListener(this);

        mIntent = getIntent();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.dialog_Title_tv:
                mIntent.putExtra(SELECT_SEX_KEY,MAN_VALUE);
                setResult(Activity.RESULT_OK,mIntent);
                finish();
                overridePendingTransition(R.anim.push_bottom_in,R.anim.push_bottom_out);
                break;
            case R.id.dialog_Content_tv:
                mIntent.putExtra(SELECT_SEX_KEY,WOMEN_VALUE);
                setResult(Activity.RESULT_OK,mIntent);
                finish();
                overridePendingTransition(R.anim.push_bottom_in,R.anim.push_bottom_out);
                break;
            case R.id.dialog_cannel_tv:
                mIntent.putExtra(SELECT_SEX_KEY,CANNEL_VALYE);
                setResult(Activity.RESULT_OK,mIntent);
                finish();
                overridePendingTransition(R.anim.push_bottom_in,R.anim.push_bottom_out);
                break;
            default:break;
        }
    }
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        finish();
        overridePendingTransition(R.anim.push_bottom_in,R.anim.push_bottom_out);
        return true;
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
        overridePendingTransition(R.anim.push_bottom_in,R.anim.push_bottom_out);
    }
}
